package cn.highedu.coolshark_product.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@Slf4j
public class PasswordEncoderConfig {
    /**
     * 为Spring Security 提供密码加密器
     * @return 密码加密器
     */
    @Bean // 交给Spring容器管理 对象的标识(id)是passwordEncoder
    public PasswordEncoder passwordEncoder() {
        PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
        log.debug("配置委托密码编辑器 {}", passwordEncoder.getClass().getName()); // 获取加密后的结果
        return passwordEncoder;
    }
}
